<?php

class test extends ActionBlock {

    public function run() {
        // Connecting, selecting database
        $link = mysql_connect('mysql-srv17204.ht-systems.ru', 'srv17204_admin', 'natti') or die('Could not connect: ' . mysql_error());
        mysql_select_db('srv17204_mysqldb') or die('Could not select database');
        mysql_set_charset('utf8', $link);
    
        // Performing SQL query
        $query = 'SELECT * FROM nomatch WHERE ru_city IS NULL OR length(trim(ru_city)) = 0';
        $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    
        // Printing results in xml
        $i = 0;
        $res = "<page>";
        while ($parts = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $id = $parts['id'];
            $enCountry = $parts['en_country'];
            $enCity = $parts['en_city'];
            $ruCountry = $parts['ru_country'];
            $res = $res
                . "<line id=\"" . htmlspecialchars($id)
                . "\" en_country=\"" . htmlspecialchars($enCountry)
                . "\" en_city=\"" . htmlspecialchars($enCity)
                . "\" ru_country=\"" . htmlspecialchars($ruCountry) . "\" />";
    
            if ($i++ > 100) {
                break;
            }
        }
        $res = $res . "</page>";
    
        $this->appendXml($res);
        
        // Free resultset
        mysql_free_result($result);
        // Closing connection
        mysql_close($link);
    }
}
?>